$OpenBSD: patch-deja-dup_preferences_Preferences_vala,v 1.1 2016/01/17 09:48:59 ajacoutot Exp $

No PackageKit on OpenBSD.

--- deja-dup/preferences/Preferences.vala.orig	Sun Jan 17 10:35:28 2016
+++ deja-dup/preferences/Preferences.vala	Sun Jan 17 10:36:17 2016
@@ -62,64 +62,6 @@ public class Preferences : Gtk.Grid
     }
   }
 
-  async void install_duplicity()
-  {
-    backup_button.sensitive = false;
-    restore_button.sensitive = false;
-
-    try {
-      var task = new Pk.Task();
-      var results = yield task.resolve_async(Pk.Filter.NOT_INSTALLED, {"duplicity"}, null, () => {});
-      if (results != null && results.get_error_code () == null) {
-
-        // Convert from List to array (I don't know why the API couldn't be friendlier...)
-        var package_array = results.get_package_array();
-        var package_ids = new string[package_array.length + 1];
-        package_ids[package_array.length] = null;
-        for (var i = 0; i < package_array.length; i++) {
-            package_ids[i] = package_array.data[i].get_id();
-        }
-
-        yield task.install_packages_async(package_ids, null, (p, t) => {
-          backup_progress.fraction = p.percentage / 100.0;
-          restore_progress.fraction = p.percentage / 100.0;
-        });
-
-        duplicity_installed = Environment.find_program_in_path("duplicity") != null;
-        if (duplicity_installed) {
-          backup_desc.everything_installed = true;
-          backup_button.label = _("_Back Up Now…");
-          restore_desc.everything_installed = true;
-          restore_button.label = _("_Restore…");
-          auto_switch.sensitive = true;
-        }
-      }
-    }
-    catch (Error e) {
-      // We don't want to show authorization errors -- either the user clicked
-      // cancel or already entered password several times.  Don't need to warn them.
-      // Oddly enough, I couldn't get error matching to work for this.  Maybe the
-      // policykit bindings I copied are incomplete.
-      if (e.message.contains("org.freedesktop.PolicyKit.Error.NotAuthorized")) {
-        warning("%s\n", e.message);
-      } else {
-        Gtk.MessageDialog dlg = new Gtk.MessageDialog (get_toplevel() as Gtk.Window,
-            Gtk.DialogFlags.DESTROY_WITH_PARENT | Gtk.DialogFlags.MODAL,
-            Gtk.MessageType.ERROR,
-            Gtk.ButtonsType.OK,
-            "%s", _("Could not install"));
-        dlg.format_secondary_text("%s", e.message);
-        dlg.run();
-        destroy_widget(dlg);
-      }
-    }
-
-    backup_progress.visible = false;
-    restore_progress.visible = false;
-    backup_button.sensitive = true;
-    restore_button.sensitive = true;
-  }
-
   Gtk.Widget make_settings_page()
   {
     var settings_page = new Gtk.Grid();
@@ -199,12 +141,7 @@ public class Preferences : Gtk.Grid
     w.halign = Gtk.Align.START;
     w.expand = false;
     (w as Gtk.Button).clicked.connect((b) => {
-      if (duplicity_installed) {
-        run_deja_dup("--restore", b.get_display().get_app_launch_context());
-      } else {
-        restore_progress.visible = true;
-        install_duplicity.begin();
-      }
+      run_deja_dup("--restore", b.get_display().get_app_launch_context());
     });
     restore_button = w as Gtk.Button;
     label_sizes.add_widget(w);
@@ -245,12 +182,7 @@ public class Preferences : Gtk.Grid
     w.halign = Gtk.Align.START;
     w.expand = false;
     (w as Gtk.Button).clicked.connect((b) => {
-      if (duplicity_installed) {
-        run_deja_dup("--backup", b.get_display().get_app_launch_context());
-      } else {
-        backup_progress.visible = true;
-        install_duplicity.begin();
-      }
+      run_deja_dup("--backup", b.get_display().get_app_launch_context());
     });
     backup_button = w as Gtk.Button;
     label_sizes.add_widget(w);
